In Julia, text is handled via two distinct architectural entities: the 32-bit Char primitive and the immutable, UTF-8 encoded String. Unlike languages where a character is a one-length string, Julia treats Char as a first-class numeric type representing a Unicode code point.
1. Type Hierarchy & Memory
Concrete Char is a $32$-bit primitive type (subtype of AbstractChar). The built-in String (subtype of AbstractString) supports the full Unicode range. While a Char is fixed-size, String is variable-width; individual characters take 1 to 4 bytes, with the transition point for ASCII occurring at $0x80(128)$.
2. Arithmetic & Comparison
Since Char represents a numeric code point, you can perform arithmetic. Use Int('a') to get 97 and Char(97) to get 'a'. Lexicographical comparisons are supported: 'X' < 'x' is true because uppercase precedes lowercase in Unicode.
| Feature | Char ('a') | String ("a") |
|---|---|---|
| Type | Char | String |
| Size | Fixed $32$-bit | Variable UTF-8 |
| Mutable | N/A (Value Type) | No (Immutable) |
Chained comparisons like 'A' <= 'X' <= 'Y' evaluate to true or false based on the Unicode sequence.